#ifndef ABSUI_CONN_CFG_WIDGET_FACTORY_HPP
#define ABSUI_CONN_CFG_WIDGET_FACTORY_HPP

#include "AbsUI/CommonUIConfig.hpp"
#include "Storage/CommonStorageConfig.hpp"
#include "utils/factory_map.hpp"
#include <boost/function.hpp>

namespace AbsUI
{

class ConnectionConfigWidget;

namespace Details
{
	typedef Storage::NameString ConnectionTypeName;
	typedef ConnectionConfigWidget* ConnectionConfigWidgetPtr__;
	typedef boost::function< ConnectionConfigWidgetPtr__ ()> ConnCfgWidgetConstructor;
	typedef utils::factory_map< ConnectionTypeName, ConnCfgWidgetConstructor> ConnCfgWidgetFactoryBase;

} // namespace Details

	// TODO: Document
class COMMON_UI_API ConnCfgWidgetFactory: private Details::ConnCfgWidgetFactoryBase
{
public:
	void registerConstructor( const Storage::NameString& typeName, const Details::ConnCfgWidgetConstructor& constructor);
	bool isTypeRegistered( const Storage::NameString& typeName) const;

	ConnectionConfigWidget* createConnCfgWidget( const Storage::NameString& typeName) const;
};

// TODO: Document
template< class ConnCfgWidgetT>
ConnCfgWidgetT* connCfgWidgetConstructor()
{
	return new ConnCfgWidgetT;
}


} // namespace AbsUI

#endif // ABSUI_CONN_CFG_WIDGET_FACTORY_HPP
